#include <iostream>
#include <string>
using namespace std;

class Solution
{
public:
    int strStr(char *haystack, char *needle)
    {
        char* a=haystack;
        while(*a!=NULL)
            {
                if(*a==*needle)
                    {
                        char* b=needle+1;
                        char* c=a+1;
                        while(*b!=NULL)
                            {
                                if(*b==*c)
                                    {
                                        b++;
                                        c++;
                                    }
                                else
                                    break;
                            }
                        if(*b==NULL)
                            return a-haystack;
                    }
                a++;
            }
        return -1;
    }
};

int main()
{
    Solution s;
    char* haystack="signature";
    char* needle="igns";
    cout<<s.strStr(haystack,needle);
}